<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <script>
            //1.await必须写在async中
            //2.await后面一般是promise对象
            //3.await返回的值是promise成功的值
            //4.await的promise失败就会抛出一个异常，需要用try...catch进行处理
            const p = new Promise((resolve,reject)=>{
                // resolve("用户数据！");
                reject("出现错误！");
            });
            async function fn(){
                try{
                    let a = await p;
                    console.log(a);
                }catch(e){
                    console.log(e);
                }
            }
            fn();
        </script>
    </body>
</html>